<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"  %>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.util.Enumeration, java.util.*, java.text.* "%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>

<%
	Connection con = null;
	Statement stmt = null;
	ResultSet rs = null;
	
	Class.forName("com.mysql.jdbc.Driver"); 		//jdbc driver load
	String url = "jdbc:mysql://localhost:3306/mydb";	//connect db
	String id = "son";
	String password = "0302";

try {
	con = DriverManager.getConnection(url, id, password);
	stmt = con.createStatement(); 			//to make the Statement for SQL

   
    StringBuilder sb = new StringBuilder();
    
    sb.append("SELECT * \n");
    sb.append("  FROM mydb.members \n");
    
    System.out.println("query = "+ sb.toString());
    rs = stmt.executeQuery(sb.toString());
    
    
 %>   
    
    <table width=100% border=2 cellpadding=1>
    <form name="delForm" id="delForm" method="post" action="address_del.jsp" >
		 <input type="hidden" name="memId" value="" />
	</form>
    <tr>
    	<td align=center> <b>Member 이름</b></td>
    	<td align=center> <b>Member ID</b></td>
    	<td align=center> <b>E-Mail</b></td>
    	<td align=center> <b>등록자</b></td>	
    	<td align=center> <b>등록시간</b></td>	
    	<td align=center> <b>수정</b></td>	
    	<td align=center> <b>삭제</b></td>
    </tr>
    	<%
    	request.setCharacterEncoding("utf-8");	// request 객체를 통해 보낼 데이터의 charset을 지정해준다.
    	while (rs.next()) {				//질의 결과 resultset 처리
    		//System.out.println(mem);
    	%>
    <tr>
    	<jsp:include page="address_list_members.jsp" flush="true">
    		<jsp:param name="listName" value='<%=rs.getString("member_name") %>'/>
    		<jsp:param name="listId" value='<%=rs.getString("member_id") %>'/>
    		<jsp:param name="listEmail" value='<%=rs.getString("email") %>'/>
    		<jsp:param name="listRegister" value='<%=rs.getString("user_id") %>'/>
    		<jsp:param name="listRegistTime" value='<%=rs.getString("update_time") %>'/>
    		
    	</jsp:include>
    </tr>
    
		<%
		}
		%>
    	</table>
<%   
} catch(Exception e) {
    e.printStackTrace();
    throw e;
} finally {
    if (rs   != null)
        try { rs.close(); } catch(Exception e) {};	//JDBC 객체 연결 해제
    if (stmt != null)
        try { stmt.close(); } catch(Exception e) {};
    if (con  != null)
        try { con.close(); } catch(Exception e) {};
}
%>
</body>
</html>